$(function() {
  $('.error').hide();
  $('textarea#sql_command').focus(function(){
    $(this).css({backgroundColor:"#FFDDAA"});
  });
  $('textarea#sql_command').blur(function(){
    $(this).css({backgroundColor:"#FFFFFF"});
  });

  $("#sql_button").click(function() {
		// validate and process form
		// first hide any result
	$('.error').hide();
		
	var sql = $("textarea#sql_command").val();
	
	if (sql == "") {
      $("label#sql_error").show();
      $("textarea#sql_command").focus();
      return false;
    }
	var dataString = 'sql_command='+ sql;	
	//alert (sql);return false;
		
	$.ajax({
      type: "POST",
      url: "sql_process.php",
      data: dataString,
      success: function(html) {
		//alert(html);
        $('.sql_result').html(html);
      }
     });
    return false;
	});
});
runOnLoad(function(){
  $("textarea#sql_command").select().focus();
});
